# Note: This file is managed by Puppet.

# Use YARN for all hadoop commands
export HADOOP_MAPRED_HOME=/usr/lib/hadoop-mapreduce

<% if @namenode_jmxremote_port -%>
# Enable NameNode JMX connections on port <%= @namenode_jmxremote_port %>
HADOOP_NAMENODE_OPTS="-Dcom.sun.management.jmxremote.port=<%= @namenode_jmxremote_port %> -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
<% end -%>
<% if @gelf_logging_enabled -%>
<%# For logging to logstash via gelf, per http://www.paluch.biz/blog/95-logging-hadoop-messages-into-logstash-using-logstash-gelf.html -%>
export HADOOP_NAMENODE_OPTS="-Dhadoop.security.logger=INFO,RFAS,gelf -Dhdfs.audit.logger=INFO,gelf $HADOOP_NAMENODE_OPTS"
export HADOOP_SECONDARYNAMENODE_OPTS="-Dhadoop.security.logger=INFO,DRFAS,gelf -Dhdfs.audit.logger=INFO,DRFAAUDIT,gelf $HADOOP_SECONDARYNAMENODE_OPTS"
<% end -%>

<% if @datanode_jmxremote_port -%>
# Enable DateNode JMX connections on port <%= @datanode_jmxremote_port %>
HADOOP_DATANODE_OPTS="-Dcom.sun.management.jmxremote.port=<%= @datanode_jmxremote_port %> -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
<% end -%>

<% if @gelf_logging_enabled -%>
HADOOP_JOBTRACKER_OPTS="-Dhadoop.security.logger=INFO,DRFAS,gelf -Dmapred.audit.logger=INFO,MRAUDIT,gelf -Dmapred.jobsummary.logger=INFO,JSA,gelf $HADOOP_JOBTRACKER_OPTS"
HADOOP_TASKTRACKER_OPTS="-Dhadoop.security.logger=ERROR,console,gelf -Dmapred.audit.logger=ERROR,console,gelf $HADOOP_TASKTRACKER_OPTS"
<%# Upstream sets the default level to ERROR to avoid logging every successful auth -%>
HADOOP_DATANODE_OPTS="-Dhadoop.security.logger=ERROR,DRFAS,gelf $HADOOP_DATANODE_OPTS"

export YARN_ROOT_LOGGER=INFO,DRFA,gelf
<%# upstream: export HADOOP_ROOT_LOGGER=INFO,DRFA,gelf -%>
<%# causes error: java.io.FileNotFoundException: /usr/lib/hadoop/logs/hadoop.log (No such file or directory) -%>
export HADOOP_ROOT_LOGGER=INFO,console,gelf
export HADOOP_JHS_LOGGER=INFO,JSA,gelf
export HADOOP_ROOT_SECURITY_LOGGER=INFO,DRFAS,gelf
<% end -%>

<% if @hadoop_heapsize -%>
# Hadoop daemons (NameNode, DataNode) will use this many MB for JVM Heap
HADOOP_HEAPSIZE=<%= @hadoop_heapsize %>
<% end -%>

<% if @hadoop_classpath -%>
export HADOOP_CLASSPATH=<%= @hadoop_classpath %>:$HADOOP_CLASSPATH
<% end -%>
<% if @java_library_path -%>
export JAVA_LIBRARY_PATH=<%= @java_library_path %>:$JAVA_LIBRARY_PATH
<% end -%>
<% if @ld_library_path -%>
export LD_LIBRARY_PATH=<%= @ld_library_path %>:$LD_LIBRARY_PATH
<% end -%>
